package com.ht.medicaltreatment.adapter

import android.graphics.Color
import android.view.View
import android.widget.TextView
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.NumberUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.AssetVO

class StockAdapter : BaseQuickAdapter<AssetVO,BaseViewHolder>(R.layout.item_stock_layout) {
    /*init {
        addChildClickViewIds(R.id.imgRemark)
    }*/
    override fun convert(holder: BaseViewHolder, item: AssetVO) {
        val root = holder.getView<View>(R.id.llTitle)
        val position = getItemPosition(item)
        holder.setText(R.id.tvCode,"${getItemPosition(item)+1}")
        holder.setText(R.id.tvName,item.assetName)
        val typeView = holder.getView<TextView>(R.id.tvStatus)
        if(item.type == 0){
            typeView.text = "缺失"
            typeView.setTextColor(context.getColor(R.color.red))
        }else if(item.type == 1){
            typeView.text = "正常"
            typeView.setTextColor(context.getColor(R.color.green))
        }else if(item.type == 2 || item.type == 3){
            typeView.text = "错放"
            typeView.setTextColor(context.getColor(R.color.yellow))
        }
        if(position % 2 == 0){
            root.setBackgroundColor(Color.parseColor("#BBD3FF"))
        }else{
            root.setBackgroundColor(context.getColor(R.color.whiteBg))
        }
    }

}
